package com.edu.pojo;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;

import javax.validation.constraints.Email;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * Classname:Person
 * Package:com.edu.pojo
 * Description:
 * Date:2020/5/24 22:29
 * User: snow
 */
@Component
// yaml注入属性值
//@ConfigurationProperties需要配置pom
@ConfigurationProperties(prefix = "person")
// 指定配置文件
// @PropertySource(value = "classpath:snow.properties")
@Validated //数据校验
public class Person implements Serializable {

	// Person{name='snow',
	// age=24, happy=false,
	// birth=Tue Dec 31 00:00:00 CST 1996,
	// maps={key1=snow, key2=旺财},
	// lists=[code, music, dog],
	// dog=Dog{name='哈哈', age=3}}

	// @Email(message = "邮箱格式错误")
	private String name;
	private Integer age;
	private Boolean happy;
	private Date birth;
	private Map<String,Object> maps;
	private List<Object> lists;
	private Dog dog;

	public Person() {
	}

	public Person(String name, Integer age, Boolean happy, Date birth, Map<String, Object> maps, List<Object> lists, Dog dog) {
		this.name = name;
		this.age = age;
		this.happy = happy;
		this.birth = birth;
		this.maps = maps;
		this.lists = lists;
		this.dog = dog;
	}

	public String getname() {
		return name;
	}

	public void setname(String name) {
		this.name = name;
	}

	public Integer getAge() {
		return age;
	}

	public void setAge(Integer age) {
		this.age = age;
	}

	public Boolean getHappy() {
		return happy;
	}

	public void setHappy(Boolean happy) {
		this.happy = happy;
	}

	public Date getbirth() {
		return birth;
	}

	public void setbirth(Date birth) {
		this.birth = birth;
	}

	public Map<String, Object> getMaps() {
		return maps;
	}

	public void setMaps(Map<String, Object> maps) {
		this.maps = maps;
	}

	public List<Object> getLists() {
		return lists;
	}

	public void setLists(List<Object> lists) {
		this.lists = lists;
	}

	public Dog getDog() {
		return dog;
	}

	public void setDog(Dog dog) {
		this.dog = dog;
	}

	@Override
	public String toString() {
		return "Person{" +
				"name='" + name + '\'' +
				", age=" + age +
				", happy=" + happy +
				", birth=" + birth +
				", maps=" + maps +
				", lists=" + lists +
				", dog=" + dog +
				'}';
	}
}
